<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>思途CMS{$coreVersion}</title>
    {template 'stourtravel/public/public_min_js'}
    {php echo Common::getCss('style.css,base.css,base_new.css'); }
    {php echo Common::getScript("st_validate.js,jquery.validate.js,jquery.validate.addcheck.js"); }
    <style>
        .info-item-block{
            padding: 0;
        }
        .info-item-block>li .item-hd{

        }
        .info-item-block>li .item-bd{

        }
    </style>
</head>
<body style="width: 420px; height:auto; overflow: hidden">

<form id="frm" name="frm">
    <ul class="info-item-block">
        <li class="list_dl">
            <input type="hidden" name="type" value="{$type}">
            <span class="item-hd">为该会员{$type}：</span>
            <div class="item-bd">
                <input type="text" class="input-text w80" data-regrex="number" data-msg="必须为数字" name="jifen" id="jifen" value="" >
                <span class="ml-5">积分</span>
            </div>
        </li>
    </ul>
    <div class="clearfix mt-15 text-c" style="margin-top: 50px;">
        <a class="btn btn-primary radius" id="btn_save" href="javascript:;">保存</a>
        <input type="hidden" id="mid" name="mid" value="{$mid}">
    </div>
</form>

<script language="JavaScript">
    var is_allow =1 ;
    var validate_action={};

    $("#frm input[name='jifen'],#frm textarea").st_readyvalidate(validate_action);
    //表单验证
    $("#frm").validate({
        focusInvalid:false,
        rules: {
            jifen:
                {
                required: true,
                min: 1,
                max: 50000,
                digits: true
            }
        },
        messages: {
            jifen:{
                required:"请输入要赠送的分值",
                min:'分值最小为1',
                max:"分值最大为50000",
                digits:"必须是数字"
            }

        },
        errUserFunc:function(element){
            //console.log(element);
        },
        errorPlacement: function(error, element) {
            error.appendTo(element.parent());
        },
        submitHandler:function(form){
            is_allow = 0 ;
            $.ajaxform({
                url   :  SITEURL+"member/add_jifen/act/save",
                method  :  "POST",
                form  : "#frm",
                dataType:'json',
                success  :  function(data)
                {
                    if(data.status)
                    {
                        ST.Util.showMsg(data.type+'积分成功!','4',2000);
                        setTimeout(function(){
                            ST.Util.closeBox();
                        },2000)
                    }
                }
            });
            return false;//阻止常规提交
        }
    });

    $(function(){
        //保存
        $("#btn_save").click(function(){
            $("#frm").submit();
        })
    })

</script>

</body>
</html>